<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<script>
		// 8,123,456,789,123
		let str = 'abcdefg'
	  // let res =	str.replace('c','*')  // 将c改成*
		// console.log(res);
		// ?=(规则)  匹配的是匹配到字符串之前的元素
		// 将c之前的前一个字符替换成*
		// let res = str.replace(/\w+(?=c)/,'*')
		// console.log(res);
		// 将c之前的所有字符换成*   str.replace(/\w+(?=c)/,'*')

		console.log('--------------------------------');
		let num = '3234567891234'
		// $& 是表示匹配到的每次的字符   + , 拼接
		let res2 = num.replace(/\d{1,3}(?=(\d{3})+$)/g,'$&,')
		console.log(res2)
	</script>
</body>
</html>